package com.boil.model;

import com.boil.qz.safekavass.model.LoginUser;
import com.boil.util.Constants;

import java.util.Date;

/**
 * 文件信息实体类。
 *
 * @author ChenYong
 * @date 2017-04-11
 */
public class FileInfo implements Comparable<FileInfo> {
    /**
     * 文件 ID
     */
    private Long id;
    /**
     * 上传者 ID
     */
    private Long userId;
    /**
     * 文件名称
     */
    private String fileName;
    /**
     * 文件路径
     */
    private String filePath;
    /**
     * 文件后缀名
     */
    private String fileSuffix;
    /**
     * 文件长度
     */
    private Long fileLength;
    /**
     * 文件描述
     */
    private String fileDesc;
    /**
     * 删除代码：0-未删除；1-已删除
     */
    private Integer isDelete;
    /**
     * 上传时间
     */
    private Date createTime;
    /**
     * 上传者
     */
    private LoginUser loginUser;

    /**
     * 默认构造器。
     */
    public FileInfo() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getFileSuffix() {
        return fileSuffix;
    }

    public void setFileSuffix(String fileSuffix) {
        this.fileSuffix = fileSuffix;
    }

    public Long getFileLength() {
        return fileLength;
    }

    public void setFileLength(Long fileLength) {
        this.fileLength = fileLength;
    }

    public String getFileDesc() {
        return fileDesc;
    }

    public void setFileDesc(String fileDesc) {
        this.fileDesc = fileDesc;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public LoginUser getLoginUser() {
        return loginUser;
    }

    public void setLoginUser(LoginUser loginUser) {
        this.loginUser = loginUser;
    }

    @Override
    public int compareTo(FileInfo o) {
        if (o == null) {
            return Constants.VALUE_0;
        }

        // 倒序
        return -(this.getCreateTime().compareTo(o.getCreateTime()));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof FileInfo)) return false;

        FileInfo fileInfo = (FileInfo) o;

        return getId().equals(fileInfo.getId());
    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("FileInfo{");
        sb.append("id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", fileName='").append(fileName).append('\'');
        sb.append(", filePath='").append(filePath).append('\'');
        sb.append(", fileSuffix='").append(fileSuffix).append('\'');
        sb.append(", fileLength=").append(fileLength);
        sb.append(", fileDesc='").append(fileDesc).append('\'');
        sb.append(", isDelete=").append(isDelete);
        sb.append(", createTime=").append(createTime);
        sb.append(", loginUser=").append(loginUser);
        sb.append('}');
        return sb.toString();
    }
}